package com.hongyuan.venue.ui.person.view_mode;

import android.app.Application;

import androidx.annotation.NonNull;

import com.hongyuan.mvvmhabitx.binding.command.BindingAction;
import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.mvvmhabitx.bus.event.SingleLiveEvent;
import com.hongyuan.venue.base.CustomViewModel;
import com.hongyuan.venue.data.MyRepository;
import com.hongyuan.venue.ui.main.activity.CodeLoginActivity;
import com.hongyuan.venue.ui.main.activity.RetrievePasswordActivity;
import com.hongyuan.venue.ui.person.activity.VersionInforActivity;

public class SettingViewModel extends CustomViewModel<MyRepository> {

    public SettingViewModel(@NonNull Application application, MyRepository model) {
        super(application, model);
    }

    //封装一个界面发生改变的观察者
    public UIChangeObservable uc = new UIChangeObservable();
    public class UIChangeObservable {
        //扫码签到
        public SingleLiveEvent<Void> outLogin = new SingleLiveEvent<>();
    }

    //退出登录
    public BindingCommand outLogin= new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            uc.outLogin.call();
        }
    });

    //版本信息
    public BindingCommand goVersion= new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            startActivity(VersionInforActivity.class);
        }
    });

    //密码服务
    public BindingCommand goMyPassword= new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            startActivity(RetrievePasswordActivity.class);
        }
    });


    /*
    * 退出登录设置用户信息为空
    * */
    public void outLogin(){
        model.saveUser(null);
        startActivity(CodeLoginActivity.class);
    }

}
